<?php

namespace app\controller;

use app\exception\ValidateException;
use app\utils\cache\Cache;
use app\utils\Json;
use support\Container;
use support\exception\BusinessException;
use support\Request;
use think\facade\Db;

class IndexController
{
    public function index(Request $request)
    {
        static $readme;
        if (!$readme) {
            $readme = file_get_contents(base_path('README.md'));
        }
        return $readme;
    }

    public function view(Request $request)
    {
        return view('index/view', ['name' => 'webman']);
    }

    public function json(Request $request)
    {
        $res = Db::name('user')->select();
//        throw new BusinessException('数据不存在');

        Cache::driver('redis')->set('test', 'test12333');
        return success('ok', $res);
    }

}
